package com.lk.test;

import com.lk.entity.Emp;

import java.text.Collator;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;

public class paixu {
    public static void main(String[] args) {
        Set<Emp>set=new TreeSet<>((o1,o2)->{
            Collator collator = Collator.getInstance(Locale.CHINA);
            int comparison = collator.compare(o1.getName(),o2.getName());

            if (comparison < 0) {
                return -1;
            } else if (comparison > 0) {
                return 1;
            }else if (comparison==0){
                int comparison2 = collator.compare(o1.getName(),o2.getName());
                if (comparison2 < 0) {
                    return -1;
                } else if (comparison2 > 0) {
                    return 1;
                } else if (comparison2==0) {
                    return o1.isSex() ?  (o2.isSex() ?  0: 1):(o2.isSex() ?  -1: 0) ;
                }
            }
            return 0;
        });
        set.add(new Emp("张三",false));
        set.add(new Emp("张三",true));
        set.add(new Emp("李四",true));
        set.add(new Emp("王五",false));
        set.forEach(emp -> System.out.println(emp));
    }
}
